<%@ page language="java" import="control.database.*,java.sql.*" pageEncoding="gb2312"%>

<%
UserConts userconts = new UserConts();
Users users=new Users();

userconts.setRealName((String)session.getAttribute("realname"));
userconts.setEmployee((String)session.getAttribute("employee"));
userconts.setSex((String)session.getAttribute("sex"));
userconts.setAddress((String)session.getAttribute("address"));
userconts.setTelephone((String)session.getAttribute("telephone"));

users.setUserName((String)session.getAttribute("username"));
users.setPassword((String)session.getAttribute("password"));
users.setEmail((String)session.getAttribute("email"));
users.setBranchID(session.getAttribute("branchid").toString());
users.setTelphone((String)session.getAttribute("telphone"));
users.setIsValid("0");

String usersql = users.Users_Add();
String contsql = "";

System.out.println(usersql);

String userid="";
try
{
DataBase db = new DataBase();
db.executeUpdate(usersql);
String uidsql = "select userid from users where username='" + session.getAttribute("username").toString() + "'";
ResultSet uidrs = db.executeQuery(uidsql);
while(uidrs.next())
{
	userid = uidrs.getString("userid").trim();
}
uidrs.close();

System.out.println("userid:"+userid);

userconts.setUserID(userid);
contsql = userconts.UserConts_ADD();
System.out.println(contsql);
db.executeUpdate(contsql);
db.closeStmt();
db.closeConn();

session.invalidate();

//out.print("<script>window.parent.location.href=='welcome.jsp'<script>");
out.print("<script>window.open('login.jsp>')<script>");
//response.sendRedirect("welcome.jsp");
}
catch(Exception e)
{
	response.sendRedirect("success_failse.jsp?flag=0");
}
%>

